﻿using System;
using System.Linq;
using System.Threading.Tasks;
using Sino.CarGoCome.Core;
using Sino.CarGoCome.Model;
using Sino.CapacityCloud.WebApi;

namespace Sino.CarGoCome.VirtualCoreData
{
    public class MockOrderService : IOrderService
    {
        public async Task<OrderListResponse> GetOrderListAsync(OrderState state, string startingPlaceCode, string destinationCode, string carLength, int startIndex,
            int count)
        {
            return new OrderListResponse()
            {
                Orders = VirtualData.VirtualData.Orders.Skip(startIndex).Take(count).ToArray()
            };
        }

        public async Task<UnitInfoResponse> GetUnitInfoAsync()
        {
            return new UnitInfoResponse()
            {
                CarLength = VirtualData.VirtualData.CarLength.ToArray(),
                PriceUnit = VirtualData.VirtualData.PriceUnit
            };
        }

        public async Task<GrabOrderResponse> GrabOrderAsync(string orderId, double price, string priceUnit, string commons)
        {
            return new GrabOrderResponse() { IsSuccesses = true, Message = "模拟抢单" };
        }

        public async Task<OrderListResponse> GetMyOrderListAsync()
        {
            return new OrderListResponse() { Orders = VirtualData.VirtualData.MyOders };
        }

        public async Task<OrderListResponse> GetSuborderListAsync(string orderId)
        {
            return new OrderListResponse() { Orders = VirtualData.VirtualData.Suboders };
        }

        public async Task<CostListResponse> GetCostListAsync(string orderId)
        {
            return new CostListResponse()
            {
                Costs =
                    new[]
                    {
                        new Cost()
                        {
                            Comment = "模拟费用",
                            Id = "1",
                            OrderId = "1",
                            PaymentDate = DateTime.Now,
                            Price = 100,
                            Progress = FeeStatus.Paid,
                            SettleType = FeeSettleType.Single,
                            Type = FeeType.AdvancePayment,
                            PaymentMethod = PaymentMethod.PetroleumOilCard
                        },
                        new Cost()
                        {
                            Comment = "模拟费用",
                            Id = "2",
                            OrderId = "1",
                            PaymentDate = DateTime.Now,
                            Price = 1000,
                            Progress = FeeStatus.Audited,
                            SettleType = FeeSettleType.Bulk,
                            Type = FeeType.ExtraCharge,
                            PaymentMethod = PaymentMethod.SinopecOilCard
                        },
                    }
            };
        }

        public async Task<RatingListResponse> GetRatingListAsync(string orderId)
        {
            return new RatingListResponse()
            {
                Ratings = new[]
                {
                    new OrderRating()
                    {
                        Attitude = 8,
                        Comment = "模拟评价",
                        Date = DateTime.Now,
                        Integrity = 9,
                        Name = "调度员",
                        Timeliness = 9,
                        TotalPoint = 8.9,
                        TransPrice = 8
                    },
                    new OrderRating()
                    {
                        Attitude = 8,
                        Comment = "模拟评价",
                        Date = DateTime.Now,
                        Integrity = 9,
                        Name = "客户",
                        Timeliness = 9,
                        TotalPoint = 8.9,
                        TransPrice = 8
                    },
                }
            };
        }

    }
}